package com.cug.nageoffer.enterprise.user.controller;

import com.cug.nageoffer.enterprise.user.service.EnterpriseUserService;
import com.cug.nageoffer.model.dto.LoginDto;
import com.cug.nageoffer.model.dto.RegisterDto;
import com.cug.nageoffer.model.entity.EnterpriseUser;
import com.cug.nageoffer.model.vo.*;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@Tag(name = "前台企业用户相关")
@RestController
@RequestMapping("/api/enterprise/user")
public class EnterpriseUserController {

    @Autowired
    private EnterpriseUserService enterpriseUserService;

    @Operation(summary = "企业端用户登录")
    @PostMapping("/login")
    public Result enterpriseUserLogin(@RequestBody LoginDto loginDto){
        log.info("用户登录，{}",loginDto);
        LoginVo loginVo = enterpriseUserService.login(loginDto);
        return Result.build(loginVo, ResultCodeEnum.SUCCESS);
    }

    @Operation(summary = "企业端用户注册")
    @PostMapping("/register")
    public Result enterpriseUserRegister(@RequestBody RegisterDto registerDto){
        log.info("用户注册：{}",registerDto);
        enterpriseUserService.register(registerDto);
        return Result.build(null, ResultCodeEnum.SUCCESS);
    }

    @Operation(summary = "企业端用户修改信息")
    @PutMapping("/update")
    public Result enterpriseUserUpdate(@RequestBody EnterpriseUser enterpriseUser){
        enterpriseUserService.enterpriseUserUpdate(enterpriseUser);
        return Result.build(null,ResultCodeEnum.SUCCESS);
    }

    @Operation(summary = "获取企业端用户数据")
    @GetMapping("/getEnterpriseUserInfo")
    public Result<EnterpriseUserVo> getEnterpriseUserInfo(){
        log.info("查询用户信息");
        EnterpriseUserVo enterpriseUserVo = enterpriseUserService.getUserInfo();
        return Result.build(enterpriseUserVo,ResultCodeEnum.SUCCESS);
    }

    @Operation(summary = "获取企业端用户收到的简历列表")
    @GetMapping("/getResume")
    public Result<List<ResumeVo>> getResume(){

        return enterpriseUserService.getResume();

    }

}
